import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StoreCouponVO, StoreCouponForm, StoreCouponQuery } from '@/api/crm/storeCoupon/types';

/**
 * 查询优惠券列表
 * @param query
 * @returns {*}
 */

export const listStoreCoupon = (query?: StoreCouponQuery): AxiosPromise<StoreCouponVO[]> => {
  return request({
    url: '/crm/storeCoupon/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询优惠券详细
 * @param id
 */
export const getStoreCoupon = (id: string | number): AxiosPromise<StoreCouponVO> => {
  return request({
    url: '/crm/storeCoupon/' + id,
    method: 'get'
  });
};

/**
 * 新增优惠券
 * @param data
 */
export const addStoreCoupon = (data: StoreCouponForm) => {
  return request({
    url: '/crm/storeCoupon',
    method: 'post',
    data: data
  });
};

/**
 * 修改优惠券
 * @param data
 */
export const updateStoreCoupon = (data: StoreCouponForm) => {
  return request({
    url: '/crm/storeCoupon',
    method: 'put',
    data: data
  });
};

/**
 * 删除优惠券
 * @param id
 */
export const delStoreCoupon = (id: string | number | Array<string | number>) => {
  return request({
    url: '/crm/storeCoupon/' + id,
    method: 'delete'
  });
};
